import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SubjectVO, SubjectForm, SubjectQuery } from '@/api/core/subject/types';

/**
 * 查询学科管理列表
 * @param query
 * @returns {*}
 */

export const listSubject = (query?: SubjectQuery): AxiosPromise<SubjectVO[]> => {
  return request({
    url: '/core/subject/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询学科管理详细
 * @param id
 */
export const getSubject = (id: string | number): AxiosPromise<SubjectVO> => {
  return request({
    url: '/core/subject/' + id,
    method: 'get'
  });
};

/**
 * 新增学科管理
 * @param data
 */
export const addSubject = (data: SubjectForm) => {
  return request({
    url: '/core/subject',
    method: 'post',
    data: data
  });
};

/**
 * 修改学科管理
 * @param data
 */
export const updateSubject = (data: SubjectForm) => {
  return request({
    url: '/core/subject',
    method: 'put',
    data: data
  });
};

/**
 * 删除学科管理
 * @param id
 */
export const delSubject = (id: string | number | Array<string | number>) => {
  return request({
    url: '/core/subject/' + id,
    method: 'delete'
  });
};
